package com.qdu.servlet;

import com.qdu.service.EmployeeService;
import com.qdu.service.impl.EmployeeServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 该Servlet负责处理删除一个员工的请求
 *
 * @author Anna
 */
@WebServlet("/des")
public class DeleteEmployeeServlet extends HttpServlet {

    EmployeeService employeeService = new EmployeeServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        ///1. 获取请求参数
        req.setCharacterEncoding("utf-8");
        String eid = req.getParameter("empId");

        //2. 调用业务逻辑，完成请求处理
        int rows=employeeService.deleteEmployee(eid);
        
        //3. 生成响应内容，这里返回受影响的行数用于判断是否修改成功
        resp.getWriter().print(rows);
    }
}
